﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using VonaJobs.DAL.DAO;

namespace VonaJobs.DAL.Gatway
{
    public class JobAjentGateway:DBGateway
    {
        public string SaveJobAgent(JobAgent jobAgent)
        {
            try
            {
                ConnectionObj.Open();
                CommandObj.CommandText =
                    string.Format("insert into tblJobAgent values(@AgentName,@Keyword,@SeekerId)");
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.Add("@AgentName", SqlDbType.NVarChar).Value = jobAgent.AgentName;
                CommandObj.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = jobAgent.Keyword;
                CommandObj.Parameters.Add("@SeekerId", SqlDbType.Int).Value = jobAgent.Seeker.Id;



                CommandObj.ExecuteNonQuery();
                return "New job ajent created successfully";
            }
            catch (Exception)
            {
                throw new Exception("Message Not Send, Server Error !");
            }
            finally
            {
                if (ConnectionObj != null && ConnectionObj.State == ConnectionState.Open)
                {
                    ConnectionObj.Close();
                }

            }
        }
        public string DeleteJobEvent(JobAgent jobAgent)
        {
            try
            {
                ConnectionObj.Open();
                CommandObj.CommandText =
                    string.Format("Delete * from tblJobAgent where Id='{0}'",jobAgent.Id);
                CommandObj.ExecuteNonQuery();
                return "Job ajent delete successfull successfully";
            }
            catch (Exception)
            {
                throw new Exception("Job ajent delete failed, Server Error !");
            }
            finally
            {
                if (ConnectionObj != null && ConnectionObj.State == ConnectionState.Open)
                {
                    ConnectionObj.Close();
                }

            }
        }
    }

}